﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <meta name="viewport" content="width=device-width" />
    <title>Stage</title>
    <link id="easyuiTheme" href="/Res/easyui/themes/metro/easyui.css" rel="stylesheet" type="text/css" />
    <link href="/Content/default.css" rel="stylesheet" />

    <script src="/Scripts/jquery-1.8.3.min.js"></script>
    <script src="/Res/easyui/jquery.easyui.min.js"></script>
    <script src="/Res/easyui/jquery.cookie.js"></script>
    <script src="/Res/easyui/locale/easyui-lang-zh_CN.js"></script>

    <script type="text/javascript">
        $(function () {
            $('#hYear').val("<%=Request.Params["Year"]%>");
            $('#hMonth').val("<%=Request.Params["Month"]%>");
            $('#hStage').val("<%=Request.Params["Stage"]%>");

            $("#Year").combobox({
                editable: false, panelHeight: "auto",
                valueField: "DictionaryName",
                textField: "DictionaryName",
                url: "/Dictionary/GetDictionaryByTypeTag?typeTag=Year",
                onLoadSuccess: function () {
                    var data = $('#Year').combobox('getData');
                    if (data.length > 0) {
                        if ($('#hYear').val() != '') {
                            $('#Year').combobox('select', ($('#hYear').val()));
                        }
                        else {
                            $('#Year').combobox('select', data[0]["DictionaryName"]);
                        }
                    }
                    $('#hYear').val('');
                }
            });

            $("#Month").combobox({
                editable: false, panelHeight: "auto",
                valueField: "DictionaryName",
                textField: "DictionaryName",
                url: "/Dictionary/GetDictionaryByTypeTag?typeTag=Month",
                onLoadSuccess: function () {
                    var data = $("#Month").combobox('getData');
                    if (data.length > 0) {
                        if ($('#hMonth').val() != '') {
                            $('#Month').combobox('select', ($('#hMonth').val()));
                        }
                        else {
                            $("#Month").combobox('select', data[0]["DictionaryName"]);
                        }
                    }
                    $('#hMonth').val('');
                }
            });

            $("#Stage").combobox({
                editable: false, panelHeight: "auto",
                valueField: "DictionaryName",
                textField: "DictionaryName",
                url: "/Dictionary/GetDictionaryByTypeTag?typeTag=TenStage",
                onLoadSuccess: function () {
                    var data = $("#Stage").combobox('getData');
                    if (data.length > 0) {
                        if ($('#hStage').val() != '') {
                            $('#Stage').combobox('select', ($('#hStage').val()));
                        }
                        else {
                            $("#Stage").combobox('select', data[0]["DictionaryName"]);
                        }
                    }
                    $('#hStage').val('');
                }
            });
        });
    </script>

    <script runat="server">
        void Page_Load(object sender, EventArgs e)
        {
            if (ViewData["ReportData"] != null)
            {
                ReportViewer1.LocalReport.ReportPath = @"bin\Report\StageReport.rdlc";
                List<Bricks.Site.Models.StageReportView> lstStageReportView = ViewData["ReportData"] as List<Bricks.Site.Models.StageReportView>;
                ReportDataSource source = new ReportDataSource();
                source.Name = "StageReportView";
                source.Value = lstStageReportView;
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.LocalReport.DataSources.Add(source);
                List<ReportParameter> lstReportParameter = new List<ReportParameter>();
                ReportParameter currentReportName = new ReportParameter();
                currentReportName.Name = "CurrentReportName";
                currentReportName.Values.Add(ViewData["CurrentReportName"] as string);
                lstReportParameter.Add(currentReportName);
                ReportParameter totalTime = new ReportParameter();
                totalTime.Name = "TotalTime";
                totalTime.Values.Add(ViewData["TotalTime"] as string);
                lstReportParameter.Add(totalTime);
                ReportViewer1.LocalReport.SetParameters(lstReportParameter);
                ReportViewer1.ZoomMode = ZoomMode.PageWidth;
                ReportViewer1.LocalReport.Refresh();
            }
        }
    </script>
</head>
<body>
    <form id="frmStageReport" runat="server">
        <div>
            <input type="hidden" id="hYear" />
            <input type="hidden" id="hMonth" />
            <input type="hidden" id="hStage" />
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <%using (Html.BeginForm("StageReport", "Report"))
              {%>
            <table style="margin-top: 5px">
                <tr>
                    <td style="width: 50px; text-align: center">年</td>
                    <td>
                        <input id="Year" name="Year" class="easyui-combobox" style="width: 70px;" />
                    </td>
                    <td style="width: 50px; text-align: center">月</td>
                    <td>
                        <input id="Month" name="Month" class="easyui-combobox" style="width: 70px;" />
                    </td>
                    <td style="width: 50px; text-align: center">旬</td>
                    <td>
                        <input id="Stage" name="Stage" class="easyui-combobox" style="width: 70px;" />
                    </td>
                    <td>
                        <input type="submit" value="预览" />
                    </td>
                </tr>
            </table>
            <%}
            %>
            <rsweb:ReportViewer ID="ReportViewer1" runat="server" AsyncRendering="false" Font-Names="Verdana" Font-Size="8pt" BackColor="#eaf6fc" Width="100%" Height="900px" ShowFindControls="false" ShowPrintButton="true">
            </rsweb:ReportViewer>
        </div>
    </form>
</body>
</html>
